package com.ruoyi.system.service.impl;

import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.PictureCommentMapper;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.domain.PictureComment;
import com.ruoyi.system.service.IPictureCommentService;

/**
 * 图片评论Service业务层处理
 * 
 * @author ruoyi
 */
@Service
public class PictureCommentServiceImpl implements IPictureCommentService 
{
    @Autowired
    private PictureCommentMapper pictureCommentMapper;

    /**
     * 查询图片评论
     * 
     * @param commentId 图片评论主键
     * @return 图片评论
     */
    @Override
    public PictureComment selectPictureCommentByCommentId(Long commentId)
    {
        return pictureCommentMapper.selectPictureCommentByCommentId(commentId);
    }

    /**
     * 查询图片评论列表
     * 
     * @param pictureComment 图片评论
     * @return 图片评论
     */
    @Override
    public List<PictureComment> selectPictureCommentList(PictureComment pictureComment)
    {
        return pictureCommentMapper.selectPictureCommentList(pictureComment);
    }

    /**
     * 新增图片评论
     * 
     * @param pictureComment 图片评论
     * @return 结果
     */
    @Override
    public int insertPictureComment(PictureComment pictureComment)
    {
        // 设置评论用户信息和评论时间
        pictureComment.setCommentUserId(ShiroUtils.getSysUser().getUserId());
        pictureComment.setCommentUserName(ShiroUtils.getSysUser().getUserName());
        pictureComment.setCommentTime(new Date());
        return pictureCommentMapper.insertPictureComment(pictureComment);
    }

    /**
     * 修改图片评论
     * 
     * @param pictureComment 图片评论
     * @return 结果
     */
    @Override
    public int updatePictureComment(PictureComment pictureComment)
    {
        return pictureCommentMapper.updatePictureComment(pictureComment);
    }

    /**
     * 批量删除图片评论
     * 
     * @param commentIds 需要删除的图片评论主键集合
     * @return 结果
     */
    @Override
    public int deletePictureCommentByCommentIds(Long[] commentIds)
    {
        return pictureCommentMapper.deletePictureCommentByCommentIds(commentIds);
    }

    /**
     * 删除图片评论信息
     * 
     * @param commentId 图片评论主键
     * @return 结果
     */
    @Override
    public int deletePictureCommentByCommentId(Long commentId)
    {
        return pictureCommentMapper.deletePictureCommentByCommentId(commentId);
    }

    /**
     * 根据图片ID查询评论列表（按时间倒序）
     * 
     * @param pictureId 图片ID
     * @return 图片评论集合
     */
    @Override
    public List<PictureComment> selectPictureCommentsByPictureId(Long pictureId)
    {
        return pictureCommentMapper.selectPictureCommentsByPictureId(pictureId);
    }
}